<template>
	<view class="content">
		<z-paging ref="paging" v-model="messageList" hide-empty-view use-page-scroll @query="queryList">
			<!-- input -->
			<view class="chatinput" slot="bottom">
				<view class="tool">
					<uni-icons type="trash" color="white" size="30" @click="deleteInfo()"></uni-icons>
					<uni-easyinput class="inputtext" v-model="comment" placeholder="请输入你的问题"></uni-easyinput>
					<button type="default" class="sendBtn" @click="sendMessage">发送</button>
				</view>

			</view>
			<!-- 聊天 -->


			<view v-for="(item,index) in messages" :key="index">

				<view>
					<view class="chatRight" v-if="item.role.indexOf('user') != -1">
						<view class="chatContent">
							<view class="messageTop">
								<text class="time">{{dateFormatter(item.createTime)}}</text>
								<text class="name"></text>
							</view>
							<view class="messageInfo">
								<view class="text">
									{{item.content}}
								</view>
							</view>
						</view>
						<view class="headImg">

							<view>
								<rich-text :nodes="getName(item)"></rich-text>
							</view>
						</view>
					</view>

					<view v-if="item.role.indexOf('assistant') != -1" class="chatLeft">
						<view class="headImg">

							<image src="../../static/logo.png" mode="">
							</image>

						</view>
						<view class="chatContent">
							<view class="messageTop">
								<text class="name">AI助手</text>
								<text class="time">{{dateFormatter(item.createTime)}}</text>
							</view>
							<view class="messageInfo">
								<view class="text">
									{{item.content}}
								</view>
							</view>
						</view>
					</view>
				</view>

			</view>
			<view style="width: 100%; text-align: center; color: #FFF;white-space: pre-wrap;font-size: 12px;" v-if="isSend">
				Ai正在为你生成答案，请等待...\n长时间没有返回，请左下角删除问答记录，重新问答</view>


		</z-paging>
	</view>


</template>
<script>
	import index from './index.js'

	export default index
</script>

<style lang="scss">
	@import './index.scss';
</style>